<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>淘贝商城 - 付款</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <style>
        .navbar-default {
            background-color: #FFA500; /* 橙黄色 */
            border-color: #E69500;
        }
        .navbar-default .navbar-brand,
        .navbar-default .navbar-nav > li > a {
            color: #FFF; /* 白色文字 */
        }
        .navbar-default .navbar-nav > .active > a,
        .navbar-default .navbar-nav > .active > a:hover,
        .navbar-default .navbar-nav > .active > a:focus {
            background-color: #E69500; /* 深一点的橙黄色 */
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">淘贝商城</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <h1>付款</h1>
        <form>
            <div class="form-group">
                <label for="cardNumber">信用卡号</label>
                <input type="text" class="form-control" id="cardNumber" placeholder="请输入信用卡号" required>
            </div>
            <div class="form-group">
                <label for="expiryDate">有效期</label>
                <input type="text" class="form-control" id="expiryDate" placeholder="MM/YY" required>
            </div>
            <div class="form-group">
                <label for="cvv">CVV</label>
                <input type="text" class="form-control" id="cvv" placeholder="CVV" required>
            </div>
            <div class="form-group">
                <label for="nameOnCard">持卡人姓名</label>
                <input type="text" class="form-control" id="nameOnCard" placeholder="请输入持卡人姓名" required>
            </div>
            <div class="form-group">
                <label for="amount">付款金额</label>
                <input type="text" class="form-control" id="amount" readonly>
            </div>
            <button type="submit" class="btn btn-success">确认付款</button>
            <a href="cart.html" class="btn btn-link">返回购物车</a>
            <a href="../index.html" class="btn btn-link">返回主页</a>
        </form>
    </div>

    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <script>
        // 计算购物车总价格并显示
        document.addEventListener('DOMContentLoaded', function () {
            const cart = JSON.parse(localStorage.getItem('cart')) || [];
            let totalAmount = 0;

            // 计算总价格
            cart.forEach(item => {
                totalAmount += parseFloat(item.price);
            });

            // 显示总价格
            document.getElementById('amount').value = `￥${totalAmount.toFixed(2)}`;
        });
    </script>
</body>
</html>